#include <iostream>
using namespace std;
#define maxn 100002
int stack[maxn], pushOrder[maxn], popOrder[maxn];
int top = 0, q, n;
bool flag = false;
void push(int val) { stack[++top] = val; };
void clear() { top = 0; };
int pop() { return stack[top--]; }
int topNum() { return stack[top]; }
int sizeStack() { return top; }
bool isEmpty() { return top == 0; }
bool isFull() { return top == maxn; }
int main()
{
    cin >> q;
    while (q--)
    {
        cin >> n;
        flag = true;
        clear();
        //pushed order
        for (int i = 0; i < n; ++i)
            cin >> pushOrder[i];
        //poped order
        for (int i = 0; i < n; ++i)
            cin >> popOrder[i];
        //print ans
        for (int i = 0, j = 0; i < n; ++i)
        {
            push(pushOrder[i]);
            while ((topNum() == popOrder[j]))
            {
                pop();
                j++;
                if (isEmpty())
                    break;
            }
        }
        if (isEmpty())
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}